home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1986 September & October / rerun-1986-09-10.d64 / loan arranger (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  4KB  |  123 lines

  1. 10 rem 64/128 loan amortization program
  2. 20 rem by jaap kroes
  3. 30 rem 03/86
  4. 40 print"[147]":poke53280,0:poke53281,0:poke646,7
  5. 50 a$="64/128 loan amortization program"
  6. 60 gosub90:a$="by  jaap  kroes"
  7. 70 gosub90:a$=" box 66,  pella, ia. 50219"
  8. 80 gosub90:fort=1to1000:nextt:goto140
  9. 90 a%=len(a$):y=a%
  10. 100 print"":forx=1toa%
  11. 110 printtab((39-a%)/2)mid$(a$,y,x)"[157][145]"
  12. 120 y=y-1:ford=1to25:nextd:nextx:return
  13. 140 print"[147]"
  14. 150 printspc(12)"l o a n  m e n u"
  15. 160 printspc(11)"1) monthly payment"
  16. 170 printspc(11)"2) loan balance (payoff)"
  17. 180 printspc(11)"3) amortize a loan":printspc(11)"4) end program"
  18. 190 geta$:ifa$=""then190
  19. 200 ifa$<"1"ora$>"4"then190
  20. 210 onval(a$)goto220,350,500,840
  21. 220 print"[147]     m o n t h l y  p a y m e n t":print
  22. 230 input"      1) loan principle ";lp
  23. 240 input"      2) loan interest  ";li
  24. 250 ir=li/12
  25. 260 input"      3) loan duration (months)";ld:print
  26. 270 x=(1-(1+ir/100)^-ld)/(ir/100)
  27. 280 mp=lp/x:mr=int(mp/0.01)*0.01
  28. 290 mr$=str$(mr+.001):mr$=mid$(mr$,2,(len(mr$)-2))
  29. 300 print"      4) monthly payment = $";mr
  30. 310 print"              another   y/n   [146]"
  31. 320 geta$:ifa$<>"y"anda$<>"n"then320
  32. 330 ifa$="n"thenrun140
  33. 340 ifa$="y"thenrun220
  34. 350 print"[147] l o a n  b a l a n c e  ( p a y o f[160]f[160])":print
  35. 360 input"    what is the loan amount";pv
  36. 370 input"    what is the payment amount";pmt
  37. 380 input"    how many payments made";n
  38. 390 input"    what is the interest rate";i
  39. 400 ri=i/12
  40. 410 x=(ri/100)+1:y=x^n:z=y*pv
  41. 420 xx=x*pmt:zz=y-1:yy=ri/100:zx=zz/yy:zy=xx*zx:ba=z-zy
  42. 430 bl=int(ba/0.01)*0.01
  43. 440 bl$=str$(bl+.001):bl$=mid$(bl$,2,(len(bl$)-2))
  44. 450 print"    remaining balance is ";bl$
  45. 460 print"              another y/n  [146]"
  46. 470 geta$:ifa$<>"y"anda$<>"n"then470
  47. 480 ifa$="n"thenrun140
  48. 490 ifa$="y"thenrun350
  49. 500 print"[147]"
  50. 510 printspc(3)"l o a n  a m o r t i z[160]a t i o n"
  51. 520 input"     amount of loan---$";a:i=a
  52. 530 input"     interest rate in %";b
  53. 540 input"     duration of loan in months";c
  54. 550 print"    do you want hard copy (y/n)"
  55. 560 getz$:ifz$<>"y"andz$<>"n"then560
  56. 570 z=0:ifz$="y"thenz=1:goto590
  57. 580 print"[147]":print" #    pmt       int     prin       bal  "
  58. 590 print:y=1
  59. 600 d=a/(((1-(1+b/1200)^-c)/(b/1200)))
  60. 610 e=b/1200*a:f=d-e:g=a-f:gosub620:goto720
  61. 620 dd=int(d/0.01)*0.01
  62. 630 ee=int(e/0.01)*0.01
  63. 640 ff=int(f/0.01)*0.01
  64. 650 gg=int(g/0.01)*0.01
  65. 660 dd$=str$(dd+.001):dd$=mid$(dd$,2,(len(dd$)-2))
  66. 670 ee$=str$(ee+.001):ee$=mid$(ee$,2,(len(ee$)-2))
  67. 680 ifee<1thenee$="0"+str$(ee+.001):ee$=mid$(ee$,2,(len(ee$)-2))
  68. 690 ff$=str$(ff+.001):ff$=mid$(ff$,2,(len(ff$)-2))
  69. 700 gg$=str$(gg+.001):gg$=mid$(gg$,2,(len(gg$)-2)):ifgg<=0thengg$="0.00"
  70. 710 return
  71. 720 ifz=1thenprint"[147]":printtab(13)" please  wait [146]"
  72. 725 ifz=1thenprinttab(13)"   printing   [146]":goto880
  73. 730 printy:printtab(11-len(dd$))"[145]"dd$:printtab(20-len(ee$))"[145]"ee$
  74. 740 printtab(28-len(ff$))"[145]"ff$:printtab(39-len(gg$))"[145]"gg$
  75. 750 c=c-1:a=g:y=y+1
  76. 760 ifc>0then600
  77. 765 gosub770:goto800
  78. 770 t=val(dd$):tt=t*(y-1):tc=tt-i:ct=int(tc/0.01)*0.01:tl=int(tt/0.01)*0.01
  79. 780 tt$=str$(tl+.001):tt$=mid$(tt$,2,(len(tt$)-2))
  80. 790 tc$=str$(ct+.001):tc$=mid$(tc$,2,(len(tc$)-2)):return
  81. 800 print"total payments = "tt$:print"total cost     =  "tc$
  82. 810 ifc=0thenprint"              another y/n   [146]"
  83. 820 geta$:ifa$<>"y"anda$<>"n"then820
  84. 830 ifa$="y"thenrun500
  85. 840 print"[145]             end program y/n   [146] "
  86. 850 geta$:ifa$<>"y"anda$<>"n"then850
  87. 860 ifa$="n"thenrun140
  88. 870 ifa$="y"thena$="* * *  t[160]h[160]a[160]n k  y o u[160][160]* * *":print"[147]":gosub90
  89. 875 print"[144]":end
  90. 880 rem *** printer routine ***
  91. 890 e$=chr$(27):h$=chr$(9)
  92. 900 open4,4:cmd4
  93. 910 print
  94. 920 print"                   **** loan amortization schedule ****"
  95. 930 print
  96. 940 print"           amount of loan     = $"a
  97. 950 print"           interest rate      =  "b"%"
  98. 960 print"           length of loan     =  "c"months"
  99. 970 print:k=0:p=1:y=1
  100. 980 print"  pmnt #        pmnt          interest        principal      balance"
  101. 990 print
  102. 1000 d=a/(((1-(1+b/1200)^-c)/(b/1200)))
  103. 1010 e=b/1200*a:f=d-e:g=a-f:gosub620
  104. 1020 y$=str$(y)
  105. 1030 print#4,""tab(5-len(y$))y$;
  106. 1040 print#4,""tab(16-len(dd$))dd$;
  107. 1050 print#4,""tab(16-len(ee$))ee$;
  108. 1060 print#4,""tab(16-len(ff$))ff$;
  109. 1070 print#4,""tab(16-len(gg$))gg$
  110. 1080 c=c-1:a=g:k=k+1:y=y+1
  111. 1090 ifk=42then1150
  112. 1100 ifc>0then1000
  113. 1110 gosub770:cmd4
  114. 1120 print:print"  total payments = "tt$
  115. 1130 print:print"             total cost = "tc$
  116. 1140 ifc=0thenprint#4:close4:print"[147]":goto810
  117. 1150 cmd4:p=p+1:print:print"        continued on next page":k=0
  118. 1155 fort=1to8:printchr$(10):next
  119. 1160 print"                                   page #"p:print:print:print
  120. 1170 print"  pmnt #        pmnt          interest        principal     balance"
  121. 1180 print
  122. 1190 goto1100
  123.